/**
 * Created by WangMing on 15/12/9.
 */
define(["../../service",
        "../../utils/i18n",
        "../../widgets/player_live_widget/player_live_widget"
        
    ],
    function(api, i18n) {
        // 定义所有相关的vmodel
        var vm = avalon.define({
            $id: "playerContainer",
            $video: {
                method: api.getVideoPlay

            },
            itemID: null,
            $error:{},
  
            $player: {},
            $videoResembleList: [],
            $skipArry: ["playerWidget", "itemID"],
            jwplayerSeek: function(second) {
                
                if(jwplayer().seek){
                    jwplayer().seek(second);
                }
            }
        });
        i18n.ngettext(" has been reviews", "%d people has been reviews", 2);


        return avalon.controller(function($ctrl) {

            // 视图渲染后，意思是avalon.scan完成
            $ctrl.$onRendered = function() {
                // console.log("$fire");
                // vm.$fire("all!initPlayer");
                // console.log("avalon.vmodels.videoplayerWidget",avalon.vmodels.videoplayerWidget)
            };
            // 进入视图
            $ctrl.$onEnter = function(param, rs, rj) {

               



            };
            // 对应的视图销毁前
            $ctrl.$onBeforeUnload = function() {
            	
                $("#jwplayerContainer").css("visibility","hidden");
                jwplayer(jwplayerContainer).stop();
                jwplayer(jwplayerContainer).resize(300,100);
                $("#jwplayerContainer").offset({bottom:0,left:-300});
              // delete avalon.vmodels.videoplayerWidget ;
            };
            $ctrl.$vmodels = [vm];
        })
    });
